(ns user.commonFunctions-test
	(:use clojure.test user.commonFunctions))

;;--------------------------------------------------------------------------

(deftest check-num-fields-find-test
		(is (= true (check-num-fields-find ["123" "456" "789"])))
		(is (= false (check-num-fields-find ["123" "ab"])))
		(is (= false (check-num-fields-find ["123" "ab12"])))
		(is (= false (check-num-fields-find ["123" "ab-"])))
)

;;--------------------------------------------------------------------------

(deftest check-num-fields-test
		(is (= true (check-num-fields ["123" "456" "789"])))
		(is (= true (check-num-fields ["123.0" "456.00"])))
		(is (= false (check-num-fields ["123" "ab"])))
		(is (= false (check-num-fields ["123" "ab12"])))
		(is (= false (check-num-fields ["123" "ab-"])))
)

;;--------------------------------------------------------------------------

(deftest format-rate-test
		(is (= "$123.00" (format-rate "123")))
		(is (= "$123.00" (format-rate "123.0")))
		(is (= "$123.00" (format-rate "123.00")))
)

;;--------------------------------------------------------------------------

(deftest check-date-test
		(is (= true (check-date "10" "04" "2010")))
		(is (= false (check-date "03" "07" "90")))
		(is (= false (check-date "31" "02" "2010")))
		(is (= false (check-date "32" "1" "2010")))
)

;;--------------------------------------------------------------------------

(deftest format-date-test
		(is (= "2010/04/10" (format-date "10" "4" "2010")))
		(is (= "2010/04/10" (format-date "10" "04" "2010")))
		(is (= "2010/04/01" (format-date "1" "4" "2010")))
		(is (= "2010/04/01" (format-date "01" "4" "2010")))
)

;;--------------------------------------------------------------------------

(deftest upperLetter-test
	(is(= "Rate"( upperLetter "rate")))
	(is(= "Rate"( upperLetter "RATE")))
	(is(= "$rate" (upperLetter "$rate")))
	(is (= " "(upperLetter " ")))
	(is (= "_rate"(upperLetter "_rate")))
)
;;--------------------------------------------------------------------------
(run-tests)
;(use :reload 'user.commonFunctions-test) to run the tests
